import 'package:flutter/material.dart';
import 'package:terminal_flutter_demo/res/user_daata_list.dart';

class CardCircleAspect extends StatelessWidget {
  CardCircleAspect({Key? key}) : super(key: key) {
    print('');
  }

  _getListItem() {
    return userDataList.map((item) {
      String avatarSource = '${item['avatar_source']}';
      String title = '${item['nickname']}';
      String subtitle = '${item['slug']}';
      return Card(
        elevation: 20,
        margin: const EdgeInsets.all(16),
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
            Radius.circular(20),
          ),
        ),
        child: AspectRatio(
          aspectRatio: 16 / 9,
          child: Column(
            children: [
              Expanded(
                flex: 1,
                child: Container(
                  color: Colors.amber,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text(title),
                      Text(subtitle),
                    ],
                  ),
                ),
              ),
              ListTile(
                // leading: ClipOval(
                //   child: Image.network(avatarSource),
                // ),
                leading: CircleAvatar(
                  backgroundImage: NetworkImage(avatarSource),
                ),
                title: Text(title),
                subtitle: Text(subtitle),
              )
            ],
          ),
        ),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: _getListItem(),
    );
  }
}
